﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

/** 
 ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
 * Description: 
 * Author: Heller (HellerSong@outlook.com)
 * CreationTime: 3/28/2015 3:43:13 PM
 ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** 
 **/
namespace DevGrammar.TestBasic
{
	[TestClass]
	public class TestDelegate
	{
		delegate void ShowString(String s);
		delegate void Show<T>(T t);

		// Two methods for adding to delegate
		public void showString01(String s)
		{
			Console.WriteLine("delegate show string1: " + s);
		}
		public void showString02(String s)
		{
			Console.WriteLine("delegate show string2: " + s);
		}


		[TestMethod]
		public void test_single_agent()
		{
			ShowString operaction = showString01;

			operaction("for delegate test");
		}

		[TestMethod]
		public void test_multicast_agent()
		{
			ShowString operactions = null;
			operactions += showString01;
			operactions += showString02;

			operactions("test test");
		}

		[TestMethod]
		public void test_show_by_using_template()
		{
			Show<String> s = showString01;
			Action<String> delegateShow = showString01;
			//Func<T1, T2, TResult>
		}
	}
}
